home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10335 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: ix.netcom.com!news
  2. From: kakima@ix.netcom.com (Kiyoshi Akima)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: for (int i(1); ...)
  5. Date: 7 Mar 1996 00:58:37 GMT
  6. Organization: Netcom
  7. Message-ID: <4hlcbt$1lf@dfw-ixnews4.ix.netcom.com>
  8. References: <4gg2j6$93g@darkstar.UCSC.EDU> <ltwx5fuqn8.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de> <4hjefu$sbd@waldorf.csc.calpoly.edu>
  9. NNTP-Posting-Host: den-co5-06.ix.netcom.com
  10. X-NETCOM-Date: Wed Mar 06  6:58:37 PM CST 1996
  11.  
  12. In <4hjefu$sbd@waldorf.csc.calpoly.edu> ostoll@galaxy.csc.calpoly.edu
  13. (Oliver Stoll) writes: 
  14. >
  15. >At htis point i just wanted to mention another incompatibility I have
  16. >noticed. There is a difference between AIX's xlC and g++ as for that
  17. >definition (so if you want to write portable code, define the variable
  18. >at the beginning of the function;):
  19. >
  20. >In xlC the scope of a variable defined in for(int i = 0, ...) is the
  21. >complete function the for() statement is contained in. In g++ however,
  22. >the validity of the int declared like that is only the for statement.
  23. >So if you write a program on AIX using i after the for statement to
  24. >decide the end vlue of the for perhaps, and compile the program on xlC
  25. >it will report you an undefined variable. And if you use the same i
  26. >with for(int i...) in two subsequent for calls with g++ AIX will tell
  27. >you in the second for statement that i is already defined so...
  28. >
  29.  
  30. Seems to me that the xlC compiler hasn't caught up with the current
  31. status of the C++ standardization process.  The scope of a variable
  32. declared in the for statement is supposed to be just the for statement.
  33. g++ does have a switch to make it behave the old way.
  34.  
  35. Kiyoshi Akima
  36. kakima@ix.netcom.com
  37.  
  38.